'use strict'
// 解决因为node16以上 导致的版本漏洞 start
// https://stackoverflow.com/questions/69692842/error-message-error0308010cdigital-envelope-routinesunsupported
const crypto = require('crypto');

/**
 * The MD4 algorithm is not available anymore in Node.js 17+ (because of library SSL 3).
 * In that case, silently replace MD4 by the MD5 algorithm.
 */
try {
  crypto.createHash('md4');
} catch (e) {
  console.warn('Crypto "MD4" is not supported anymore by this Node.js version');
  const origCreateHash = crypto.createHash;
  crypto.createHash = (alg, opts) => {
    return origCreateHash(alg === 'md4' ? 'md5' : alg, opts);
  };
}
// 解决因为node16以上 导致的版本漏洞 end
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin

// const path = require('path')
module.exports = {
  publicPath: '/',
  lintOnSave: false,
  // webpack-dev-server 相关配置
  devServer: {
    host: '0.0.0.0',
    port: 8063,
    open: true,
    proxy: {
      "/dev-api": {
        //  target: `http://192.168.10.111:9000`,
        target: `http://192.168.10.231:10001`,
        changeOrigin: true,
        pathRewrite: {
          "^/dev-api": "",
        },
      },
    },
  },

  css: {
    // css预设器配置项
    loaderOptions: {
      // pass options to sass-loader
      sass: {
        // 引入全局变量样式,@使我们设置的别名,执行src目录
        additionalData: `@import "@/css/element-variable.scss";`
      }
    }
  },
  configureWebpack: {
    plugins: [
      // new BundleAnalyzerPlugin()
    ]
  }
}
